﻿package 
{
    import GameMainUI.*;
    import com.core.*;
    import com.sh.game.consts.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import control.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.net.*;
    import flash.utils.*;
    import morn.core.components.*;
    import view.message.*;

    public class GameMainUI extends Sprite implements IMainUI
    {
        private var draw:BitmapScale9Drawer;
        private var _tips:Sprite;
        private var _flashUICon:Sprite;
        private var _alertCon:Sprite;
        private var bit:Bitmap;
        private var _mainui:MainUI;

        public function GameMainUI()
        {
            return;
        }// end function

        public function init(param1:Object, param2:Object, param3:Object, param4:Object, param5:Object) : void
        {
            var _loc_6:Stage = null;
            var _loc_7:Control = null;
            App.leisureMloader.waiting = true;
            App.leisureMloader.lock();
            MornConfig.touchScrollEnable = false;
            this.initUIData();
            this._mainui = new MainUI(param3, param1, param2, param5);
            _loc_6 = GlobalLayer.instance.flashStage;
            this._flashUICon = param1 as Sprite;
            this._tips = param3 as Sprite;
            this._tips.mouseChildren = false;
            this._tips.mouseEnabled = false;
            this._alertCon = param4 as Sprite;
            Alert.init(_loc_6);
            Alert2.init(_loc_6);
            Fcmalert.init(_loc_6);
            if (_loc_6)
            {
                _loc_6.addEventListener(Event.RESIZE, this.resizeHandler);
                this.loadDanger();
                _loc_7 = Control.create(DangerControl, GlobalLayer.instance.danger);
                ModelProxy.addObserver("danger", _loc_7);
            }
            return;
        }// end function

        private function initUIData() : void
        {
            var _loc_2:Class = null;
            var _loc_3:ByteArray = null;
            var _loc_4:Object = null;
            var _loc_5:String = null;
            var _loc_1:* = new Object();
            for each (_loc_2 in BindPluginClass.dats)
            {
                
                _loc_3 = new _loc_2;
                _loc_3.uncompress();
                _loc_4 = _loc_3.readObject();
                for (_loc_5 in _loc_4)
                {
                    
                    _loc_1[_loc_5] = _loc_4[_loc_5];
                }
                _loc_3.clear();
            }
            View.xmlMap = _loc_1;
            return;
        }// end function

        private function loadDanger() : void
        {
            var _loc_1:String = "assets/images/other/danger.png";
            var _loc_2:* = new Loader();
            _loc_2.load(new URLRequest(Config.getUrl(_loc_1, ResourceType.NORMAL)));
            _loc_2.contentLoaderInfo.addEventListener(Event.COMPLETE, this.loaded);
            return;
        }// end function

        protected function loaded(event:Event) : void
        {
            var _loc_2:* = event.currentTarget.content;
            this.draw = new BitmapScale9Drawer(_loc_2.bitmapData, new Rectangle(100, 100, 110, 110));
            this.draw.setSize(GlobalLayer.instance.flashStage.stageWidth, GlobalLayer.instance.flashStage.stageHeight);
            this.draw.draw(GlobalLayer.instance.danger.graphics);
            return;
        }// end function

        protected function resizeHandler(event:Event) : void
        {
            var _loc_2:* = GlobalLayer.instance.flashStage;
            if (this.draw)
            {
                this.draw.setSize(GlobalLayer.instance.flashStage.stageWidth, GlobalLayer.instance.flashStage.stageHeight);
                this.draw.draw(GlobalLayer.instance.danger.graphics);
            }
            return;
        }// end function

        public function show() : void
        {
            return;
        }// end function

    }
}
